package com.xjtu.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjtu.project.common.utls.SessionUtilsUser;
import com.xjtu.project.model.domain.User;
import com.xjtu.project.service.UserService;
import com.xjtu.project.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 86185
* @description 针对表【user】的数据库操作Service实现
* @createDate 2025-07-04 18:26:58
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(User user) {
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getUsername,user.getUsername()).eq(User::getPassword,user.getPassword());
        User one = userMapper.selectOne(wrapper);
        SessionUtilsUser.saveCurrentUserInfo(one);
        return one;
    }
}




